<template>
  <div class="app-container">
    <el-card>
      <!--用户数据-->
      <el-form :model="queryParams" ref="queryForm" size="small" label-width="100px">
        <el-row>
          <el-col :span="6">
            <el-form-item label="姓名">
              <el-input v-model.trim="queryParams.name" @input="handleQuery" placeholder="输入内容" clearable
                @keyup.enter.native="handleQuery" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="学号">
              <el-input v-model.trim="queryParams.stNumber" @input="handleQuery" placeholder="输入内容" clearable
                @keyup.enter.native="handleQuery" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="学院" prop="xyId">
              <el-select v-model="queryParams.xyId" @change="handleQuery('学院')" filterable placeholder="请选择" clearable>
                <el-option v-for="item in proxyList" :key="item.id" :label="item.name" :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6" v-if="queryParams.xyId != null">
            <el-form-item label="年级" prop="njId">
              <el-select v-model="queryParams.njId" @change="handleQuery('年级')" filterable placeholder="请选择" clearable>
                <el-option v-for="item in pronjList" :key="item.id" :label="item.name" :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6" v-if="queryParams.njId != null">
            <el-form-item label="专业" prop="zyId">
              <el-select v-model="queryParams.zyId" @change="handleQuery('专业')" filterable placeholder="请选择" clearable>
                <el-option v-for="item in prozyList" :key="item.id" :label="item.name" :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6" v-if="queryParams.zyId != null">
            <el-form-item label="班级" prop="clId">
              <el-select v-model="queryParams.clId" filterable @change="getList" placeholder="请选择" clearable>
                <el-option v-for="item in probjList" :key="item.id" :label="item.name" :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="1">
            <el-form-item label-width="50px">
              <el-button type="primary" icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>

      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button type="primary" :disabled="tableList.length === 0" plain icon="el-icon-plus" size="mini"
            v-hasPermi="['score:export:scoreExport']" @click="handleExport">导出</el-button>
        </el-col>
      </el-row>

      <el-table v-loading="loading" :data="tableList">
        <el-table-column type="index" align="center" />
        <el-table-column label="学生姓名" width="80" align="center" key="name" prop="name" :show-overflow-tooltip="true" />
        <el-table-column label="学号" align="center" key="stNumber" prop="stNumber" :show-overflow-tooltip="true" />
        <el-table-column label="学院" align="center" key="xyName" prop="xyName" :show-overflow-tooltip="true" />
        <el-table-column label="年级" width="50" align="center" key="njName" prop="njName" :show-overflow-tooltip="true" />
        <el-table-column label="专业" align="center" key="zyName" prop="zyName" :show-overflow-tooltip="true" />
        <el-table-column label="班级" align="center" key="bjName" prop="bjName" :show-overflow-tooltip="true" />
        <el-table-column label="基础劳动 X 48%" align="center" key="userjcldCj" prop="userjcldCj"
          :show-overflow-tooltip="true" />
        <el-table-column label="社会公益活动 X 8%" align="center" key="userldgyCj" prop="userldgyCj"
          :show-overflow-tooltip="true" />
        <el-table-column label="劳动成果 X 8%" align="center" key="userldcgCj" prop="userldcgCj"
          :show-overflow-tooltip="true" />
        <el-table-column label="劳动总结报告 X 16%" align="center" key="userldzjCj" prop="userldzjCj"
          :show-overflow-tooltip="true" />
        <el-table-column label="实践成绩 X 80%" align="center" key="usersjCj" prop="usersjCj" :show-overflow-tooltip="true" />
        <el-table-column label="理论课成绩 X 20%" width="70" align="center" key="userllCj" prop="userllCj"
          :show-overflow-tooltip="true" />
        <el-table-column label="总成绩" width="70" align="center" key="userAllCj" prop="userAllCj"
          :show-overflow-tooltip="true" />
      </el-table>

      <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
        @pagination="getList" />
    </el-card>
  </div>
</template>

<script>
import { exportList } from "@/api/project/probj";
import { listProxy, listProzy, listPronj, listProbj } from "@/api/project/prouser";
export default {
  name: "integralExport",
  data() {
    return {
      loading: false, // 遮罩层
      total: 0, // 总条数
      tableList: [],
      proxyList: [], // 学院
      pronjList: [], // 年级
      prozyList: [], // 专业
      probjList: [], // 年级
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
    };
  },
  created() {
    this.getList();
    this.getListProxy();
  },
  methods: {
    // 列表
    getList() {
      exportList({ ...this.queryParams }).then(res => {
        this.total = res.total;
        this.tableList = res.rows;
      });
    },
    // 查询学院
    getListProxy() {
      listProxy().then(response => {
        this.proxyList = response.rows;
      });
    },
    // 查询年级
    getListPronj(value) {
      if (value) {
        listPronj({
          pId: value
        }).then(response => {
          this.pronjList = response.rows;
        });
      };
      this.queryParams.zyId = null;
      this.queryParams.clId = null;
    },
    // 查询专业
    getListProzy(value) {
      var map = {};
      map.pId = value;
      listProzy(map).then(response => {
        this.prozyList = response.rows;
      });
      this.queryParams.clId = null
    },
    // 查询班级
    getListProbj(value) {
      var map = {};
      map.pId = value;
      listProbj(map).then(response => {
        this.probjList = response.rows;
      });
      this.queryParams.clId = null
    },
    /** 搜索按钮操作 */
    handleQuery(type) {
      this.queryParams.pageNum = 1;
      if (type == '学院') {
        this.prozyList = [];
        this.queryParams.njId = undefined;
        this.queryParams.zyId = undefined;
        this.queryParams.clId = undefined;
        this.getListPronj(this.queryParams.xyId);
      }
      if (type == '年级') {
        this.queryParams.zyId = undefined;
        this.queryParams.clId = undefined;
        this.getListProzy(this.queryParams.njId);
      }
      if (type == '专业') {
        this.queryParams.clId = undefined;
        this.getListProbj(this.queryParams.zyId);
      }
      this.getList();
    },
    // 重置
    resetQuery() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 10,
      };
      this.getList();
    },

    /** 导出按钮操作 */
    handleExport() {
      this.download('record/card/export', {
        ...this.queryParams
      }, `成绩导出.xlsx`)
    }
  },
};
</script>
<style scoped lang="scss">
::v-deep .el-select {
  width: 100%;
}
</style>
